// 仅可在Web端使用，APP端无法运行
// BMapGL：'https://api.map.baidu.com/api?v=1.0&type=webgl&callback=initBMap&ak=自己的ak'
// BMapGL API: 'https://lbsyun.baidu.com/index.php?title=jspopularGL/guide/show'
// BMap：'https://api.map.baidu.com/api?v=2.0&callback=initBMap&ak=自己的ak'
// 异步加载方法
export function BMapLoader() {
	return new Promise((resolve, reject) => {
		if (window.BMapGL) {
			resolve(window.BMapGL)
		} else {
			const script = document.createElement('script')
			script.type = 'text/javascript'
			script.src = 'https://api.map.baidu.com/api?v=1.0&type=webgl&callback=initBMap&ak=Af6FfpOOZrHT1Ff2enuUKMZgjz4NfQ3W'
			script.async = true
			script.onerror = reject
			document.head.appendChild(script)
		}
		window.initBMap = function() {
			resolve(window.BMapGL)
		}
	})
}
